package com.gcit.seniorWish.web.core.beetl;

import cn.hutool.core.date.DateUtil;
import com.gcit.seniorWish.web.common.constant.factory.ConstantFactory;
import com.gcit.seniorWish.web.config.properties.BussProperties;
import com.gcit.seniorWish.web.core.util.KaptchaUtil;
import com.gcit.seniorWish.core.util.ToolUtil;
import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

public class BeetlConfiguration extends BeetlGroupUtilConfiguration {

	//注入业务用参数配置
	@Autowired
	private BussProperties bussProperties;

	@Override
	public void initOther() {

		groupTemplate.registerFunctionPackage("shiro", new ShiroExt());
		groupTemplate.registerFunctionPackage("tool", new ToolUtil());
		groupTemplate.registerFunctionPackage("date", new DateUtil());
		groupTemplate.registerFunctionPackage("kaptcha", new KaptchaUtil());
		groupTemplate.registerFunctionPackage("constant", ConstantFactory.me());

		//设置共享变量
		Map<String,Object> sharedVars = new HashMap<String,Object>();
		sharedVars.put("bussProperties", bussProperties);
		groupTemplate.setSharedVars(sharedVars);
	}

}
